<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>
<div  style="text-align: center">
    <br>
    邮箱:<input type="text" name="email" id="email" value="dchuan680@163.com">
    <br>
    <br>
    密码:<input type="text" name="password" id="password" value="111111">
    <br><br>
    <input type="submit" id="submit" value="登录">
    <br><br>
    <a href="http://127.0.0.1/static/regist.html" id="regist">注册新账号</a>
</div>
<script>
    function confirm() {
        var email = $('#email').val();
        var password = $('#password').val();
        if(email == "" || password == "") {
            alert('账号密码均不能为空!')
        } else {
            $.ajax({
                url: 'http://127.0.0.1/api/user/login/'+email+'/'+password,
                success:function(result) {
                    setCookie("token",result,1)
                    window.location.href="http://127.0.0.1/static/index.html";
                }
            })
        }
    }
    $('#submit').click(function() {
        confirm();
    })

    function setCookie(cname,cvalue,exdays)
    {
        var d = new Date();
        d.setTime(d.getTime()+(exdays*24*60*60*1000));
        var expires = "expires="+d.toGMTString();
        document.cookie = cname + "=" + cvalue + "; " + expires;
    }
</script>

</body>
</html>